package leetcode.N1_N100;

import leetcode.comm.ListNode;

import java.math.BigDecimal;

/**
 * @author xiwai [hww282306@alibaba-inc.com]
 * @version 1.0
 * @date 2020/10/14 4:05 下午
 */
public class N82 {

    public static void main(String[] args) {
        BigDecimal orderPrincipalTotal = BigDecimal.valueOf(20);
        BigDecimal itemWalletTotal = BigDecimal.valueOf(100);
        BigDecimal itemPrice = BigDecimal.valueOf(10);
        System.out.println(orderPrincipalTotal.multiply(itemPrice).divide(itemWalletTotal, 0, BigDecimal.ROUND_HALF_UP).longValue());
    }

    public static ListNode deleteDuplicates(ListNode head) {
        ListNode sentry = new ListNode(0);
        ListNode lastNode = sentry;
        ListNode currentNode = head;
        while (currentNode != null) {
            ListNode next = currentNode.next;
            if (next == null || next.val > currentNode.val) {
                lastNode = lastNode.next = currentNode;
                currentNode = currentNode.next;
            } else {
                // 过滤掉当前取值的所有参数
                int val = currentNode.val;
                while (currentNode != null && currentNode.val == val) {
                    currentNode = currentNode.next;
                }
                lastNode.next = currentNode;
            }
        }
        return sentry.next;
    }

}
